﻿using System;
using System.Collections.Generic;
using System.ServiceManager.Facade;
using Microsoft.EnterpriseManagement.UI.WpfWizardFramework;
using Microsoft.EnterpriseManagement.UI.SdkDataAccess;
using Microsoft.EnterpriseManagement.ConsoleFramework;
using Microsoft.EnterpriseManagement.Common;
 

namespace ServiceManager.TFSIntegration
{
    public class TFSAdminConsoleCommand : ConsoleCommand
    {

        private readonly Guid tfsAdminSettingsObjectId = new Guid("7D1BDE3E-9D65-5CB1-64F6-53165B1C3F29");

        public override void ExecuteCommand(IList<NavigationModelNodeBase> nodes, NavigationModelNodeTask task, ICollection<string> parameters)
        {

            var tfsSetting = SCSMServer.GetObject<EnterpriseManagementObject>(tfsAdminSettingsObjectId);

            var wizard = new WizardStory
                             {
                                 WizardWindowTitle = "Edit TFS Integration Settings",
                                 WizardData = new TFSAdminWizardData(tfsSetting)
                             };


            wizard.AddLast(new WizardStep("TFS Configuration", typeof(TFSAdminSettingsConfigurationPage), wizard.WizardData));

            var wizardWindow = new PropertySheetDialog(wizard);

            bool? dialogResult = wizardWindow.ShowDialog();
            if (dialogResult.HasValue && dialogResult.Value)
            {
                RequestViewRefresh();
            }
        }
    }
}